package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 壮哥
 * @Date 2021/9/21/13:14
 */
@Api(value = "敏感词管理API接口",tags = "敏感词管理API接口",description = "管理敏感词相关接口")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {
    @Autowired
    private AdSensitiveService sensitiveService;
    @ApiOperation(value="分页查询敏感词列表",notes = "按照name模糊查询,分页查询 按照ord升序")
    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDTO dto){
        return sensitiveService.findByNameAndPage(dto);
    }

    @ApiOperation("敏感词新增")
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdSensitive sensitive){
        return sensitiveService.insert(sensitive);
    }


    @ApiOperation("敏感词修改")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive sensitive){
        return sensitiveService.update(sensitive);
    }


    @ApiOperation("敏感词删除")
    @GetMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return sensitiveService.deleteById(id);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives(){
        return sensitiveService.selectAllSensitives();
    }
}
